#coding=utf-8
import sys
import time
import lc_libs


while True:
	today=time.strftime('%Y%m%d',time.localtime())
	today_old=today
	filename='D:/cffex/biTransClientV3/Log/Log'+today+'.txt'
	try:
		logfile=open(filename,'rb')
	except IOError:
		print "IOError"
		time.sleep(1)
		continue
	while True:
		today=time.strftime('%Y%m%d',time.localtime())
		if today<>today_old:
			logfile.close()
			time.sleep(1)
			break
		strs=""
		line=logfile.readline()
		if line.strip("\n")=="":
			continue
		for i in line:
			strg=ord(i)^ord('z')
			strs=strs+chr(strg)
		for message in strs.split("\n"):
			print message
			if "增量还原出错" in message:
				if "增量行情的基准全量不匹配" in message:
					output="SHHQ1 LightCam Node:SHHQ1 AlertGroup:BizLogMonitor AlertKey:"+filename+" Severity:4 Type:1 Summary:ZLHYCC ZLHQDJZQLBPP"
					lc_libs.lc_alert(output)
					print output
					time.sleep(0.1)
					continue
				output="SHHQ1 LightCam Node:SHHQ1 AlertGroup:BizLogMonitor AlertKey:"+filename+" Severity:4 Type:1 Summary:ZLHYCC"
				lc_libs.lc_alert(output)
				print output
				time.sleep(0.1)
		time.sleep(0.1)
	time.sleep(1)	
